package com.yycx.module.user.provider.controller;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.common.utils.ApiAssert;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.module.user.client.entity.SysHtml;
import com.yycx.module.user.provider.service.SysHtmlService;
import com.yycx.module.user.provider.service.SysSliderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author: zyf
 * @date: 2018/11/9 15:43
 * @description: 基础服务模块接口, 不需要登录鉴权的接口
 */
@Api(tags = "基础模块-公共接口")
@Controller
@RequestMapping("/common")
public class SysCommonController {

    @Autowired
    private SysHtmlService htmlService;

    /**
     * 获取服务协议
     */
    @GetMapping(value = "/html/getByCode")
    public String getByCode(ModelMap map, String code, String title) {
        ApiAssert.isNotEmpty("参数不能为空", code);
        SysHtml html = htmlService.findByCodeOrId(code);
        if (FlymeUtils.isEmpty(html)) {
            html = new SysHtml();
            html.setHtmlCode(code);
            html.setIsParent(0);
            html.setParentId(1L);
            html.setHtmlType(1);
            html.setHtmlStatus(0);
            html.setHtmlContent(title);
            html.setHtmlTitle(title);
            htmlService.save(html);
        }
        map.addAttribute("html", html);
        return "html";
    }


    /**
     * 分享APP下载页面
     */
    @RequestMapping(value = "/download")
    public String download(ModelMap map, String type, String courseId) {
        return "download";
    }

}
